"""
基于numpy.ndarray 的技术分析指标
输入的数据都为 ndarray
输出是一个或多个 ndarray

"""

import numpy as np
from numpy import ndarray

from .pd_template import BaseInd


class RangeMethod:
    # 绝对距离，是一差值
    absolute = ['a', 'absolute']
    # 相对距离，是一百分比
    relative = ['r', 'relative']
    # 用真实波幅来认定的可变距离
    tr = ['tr', 'atr']


class ZigTick(BaseInd):

    def __init__(self, params, method: str = 'a'):
        super(ZigTick, self).__init__(params)
        if method in RangeMethod.absolute:
            self.on_tick = self.on_absolute
            self.on_ticks = self.on_absolutes
        elif method in RangeMethod.relative:
            self.on_tick = self.on_relative
            self.on_ticks = self.on_relatives
        else:
            self.on_tick = self.on_tr
            self.on_ticks = self.on_trs

    def on_absolute(self, tick):
        """

        :param tick:
        :return:
        """

    def on_absolutes(self, ticks):
        """

        :param ticks:
        :return:
        """
        rg = getattr(self, 'abs_range', 10)
        self.ticks = ticks
        lps = self.lps
        data_len = len(lps)
        p = [0] * data_len  # peak
        pp = [0] * data_len  # peak position
        pok = [0] * data_len  # 确认 peak
        pis = [0] * data_len  #
        v = [0] * data_len  # valley
        vp = [0] * data_len  # valley position
        vok = [0] * data_len  #
        vis = [0] * data_len  #
        pok_p = [0] * data_len  # 峰确认位置
        pok_v = [0] * data_len  # 峰确认价格
        vok_p = [0] * data_len  # 谷确认位置
        vok_v = [0] * data_len  # 谷确认价格
        pv_flag = [0] * data_len  # 峰谷标志

        cur_pv = 0  # 1=peak,-1=valley, 0=unknown
        # p[i] = h[i]
        # v[i] = l[i]
        # pp[i] = i
        # vp[i] = i

    def on_relative(self, tick):
        """

        :param tick:
        :return:
        """

    def on_relatives(self, ticks):
        """

        :param ticks:
        :return:
        """

    def on_tr(self, tick):
        """

        :param tick:
        :return:
        """

    def on_trs(self, ticks):
        """

        :param ticks:
        :return:
        """
